<?php 
class sysPagesAction extends AdminMaster{
	public function showList(){
		$this->data['list']			 		= SysPages::getDataList($this->data['pagination']);
		$this->data['pagination']['total']		= SysPages::getDataListCount();
		$this->data['pagination']['router']		= 'sys_page';
		$this->data['pagination']['params']		= $this->data['filter'];
	}
	public function delRecord(){
		
	}
	public function disableRecord(){
		
	}
	public function enableRecord(){
		
	}
	public function saveOrder(){
		
	}
	public function addnew(){
		
	}
	public function edit(){
		$this->setTemplate('sysPagesForm');

		$form = new SysPagesForm();
		if($this->data['is_post']){
			$form->bind($this->formData);
			if($form->isValid()){	
				$this->formData['id'] = $this->data['id'];
				if(SysPages::insertUpdate($this->formData)){
					$this->data['result']	= __('edit_success');
				}else{
					$this->data['result']	= sprintf(__('edit_error'), sfConfig::get('app_email_admin')) ;
				}
			}else{
				#foreach($form->getErrorSchema()->getErrors() as $e) {
				#	echo $e->__toString();
				#}
				#die;
			}
		}else{
			$data = SysPages::getDataByIdAdmin($this->data['id']);
			if(count($data)<0){
				$this->redirect($this->data['redirect']);
			}else{
				$this->formData = array(
						'is_enabled' => '1',
						'_csrf_token'=> $form->getCSRFToken()
				);
				foreach($this->data['langs'] as $lang){
					$this->formData['content_'.$lang] = $data['SysPagesI18n'][$lang]['content'];
					
				}
				$form->bind($this->formData);

			}
		}
		$this->setVar('form', $form);
	}
	
}